package com.holike.crm.activity.analyze;

import android.app.Dialog;
import android.os.Build;
import android.os.Bundle;

import com.holike.crm.R;
import com.holike.crm.base.BaseActivity;
import com.holike.crm.bean.WoodenDoorBean;
import com.holike.crm.dialog.LoadingTipDialog;
import com.holike.crm.fragment.analyze.WoodenDoorDealerFragment;
import com.holike.crm.fragment.analyze.WoodenDoorDefaultFragment;
import com.holike.crm.presenter.activity.WoodenDoorPresenter;
import com.holike.crm.view.activity.WoodenDoorView;


/**
 * Created by pony on 2019/8/28.
 * Copyright holike possess 2019.
 * 木门业绩报表
 */
public class WoodenDoorActivity extends BaseActivity<WoodenDoorPresenter, WoodenDoorView> implements WoodenDoorView {
    @Override
    protected boolean isFullscreen() {
        return Build.VERSION.SDK_INT < Build.VERSION_CODES.M;
    }

    @Override
    protected WoodenDoorPresenter attachPresenter() {
        return new WoodenDoorPresenter();
    }

    @Override
    protected int getLayoutResourceId() {
        return R.layout.activity_product_trading;
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        super.init(savedInstanceState);
        setTitle(getString(R.string.report_item18_title));
        getData();
    }

    private void getData() {
        showLoading();
        mPresenter.getData(null, null, null);
    }

    @Override
    protected Dialog getLoadingDialog() {
        return new LoadingTipDialog(this);
    }

    @Override
    public void onSuccess(WoodenDoorBean bean) {
        dismissLoading();
        setExtra("wooden-door-bean", bean);
        if (bean.isDealer()) {
            setTranslucentStatus();
            replace(new WoodenDoorDealerFragment());
        } else {
            replace(new WoodenDoorDefaultFragment());
        }
    }

    @Override
    public void onFailure(String failReason) {
        dismissLoading();
        showShortToast(failReason);
    }

    @Override
    protected void onDestroy() {
        removeExtra("wooden-door-bean");
        super.onDestroy();
    }
}
